using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace OpenEPN
{
    public partial class fen_AjoutProduitClient : Form
    {
        List<DA.General.Products> products;

        public fen_AjoutProduitClient(DA.General.Customers _customer)
        {
            InitializeComponent();
            textBox1.Text = _customer.Prenom + " " + _customer.Nom;
            products = new List<DA.General.Products>();
            products = BU.General.ProductsManager.Instance.GetProducts();
            comboBox1.DataSource = products;
            comboBox1.DisplayMember = "Nom";
            
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            textBox3.Text = Convert.ToString(Convert.ToDouble(textBox2.Text) *Convert.ToDouble(numericUpDown1.Value));
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (DA.General.Products product in products)
            {
                if (comboBox1.Text == product.Nom)
                {
                    textBox2.Text = Convert.ToString(product.Prix);
                }
            }
        }
    }
}